package com.zxkj.login.repository.activity;


import androidx.lifecycle.LifecycleOwner;

import com.allen.library.interceptor.Transformer;
import com.allen.library.observer.CommonObserver;
import com.allen.library.observer.LoginCommonObserver;
import com.czy.basecommon.utils.base.BaseRepository;
import com.czy.basecommon.utils.base.StateLiveData;
import com.czy.basecommon.utils.constant.ItrackConstant;
import com.czy.basecommon.utils.language.SPUtil;
import com.czy.basecommon.utils.tools.ActivityTool;
import com.czy.basecommon.utils.tools.SPUtils;
import com.zxkj.login.net.RadomApiHelper;
import com.zxkj.login.net.ResponseLogin;

import java.util.HashMap;

public class LoginRepository extends BaseRepository {
    public LoginRepository() {

    }

    public void login(String textEx, String ex, MyBaseDataCallBack mDataCallBack){

        HashMap<String,Object> map=new HashMap<String, Object>();
        map.put("LoginId", textEx);
        map.put("Password",ex);
        map.put("Lang", "0");
        map.put("Device", "1");

        RadomApiHelper.geRadomApi()
                .Login(map)
                .compose(Transformer.<ResponseLogin>switchSchedulers())
                .subscribe(new LoginCommonObserver<ResponseLogin>() {
                    @Override
                    protected void onError(String errorMsg,String errorBody) {

                        mDataCallBack.onDataFailCallBack(errorMsg,errorBody);
                    }

                    @Override
                    protected void onSuccess(ResponseLogin responseLogin) {
                        mDataCallBack.onDataSuccessCallBack(responseLogin);
                    }
                });


    }
}
